<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	
	<body>
		<div class="breadcrumbs" id="breadcrumbs">
	
			<ul class="breadcrumb">
				<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
				<li>用户中心</li>
				<li class="active">导入用户</li>
			</ul>
			
		</div>
		
		<div class="page-content">
			<div class="page-header">
							
			</div> 
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" onsubmit="return uploadExcel();" role="form" id="uploadForm" name="uploadForm" target='frameFile' method="post" enctype="multipart/form-data">
						
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">文件模板下载示例：<a href="${ctx}/upload/BatchUser.xlsx">点击下载</a></label>
						</div>
						
						<div class="form-group" >
							<label class="col-sm-3 control-label no-padding-right" for="form-field-1">文件</label>
							<div class="col-sm-9">
								<input type="file" id="excel"  name="excel" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" placeholder="请选择数据文件" onchange="setValue(this.value)" class="col-xs-10 col-sm-5"  />
							</div>
							<div class="error" style="margin:6px 0 0 112px;display: block;"></div>
						</div>
					
						<div class="clearfix form-actions">
							<div class="col-md-offset-3 col-md-9">
								<button class="btn btn-info" type="submit">
									<i class="icon-ok bigger-110"></i>提交
								</button>
							</div>
						</div>
						
					</form>		
				</div>
							
			</div>
		</div>
		
		<script type="text/javascript">
		function uploadExcel() {
			var file=$("#excel");
            if($.trim(file.val())==''){
            	$(".error").html("* 请选择文件");
                   return false;
             }
		    var formData = new FormData($("#uploadForm")[0]);
			var datastr = new Object();
			var result = true;
				$.ajax({
				url: "${ctx}/sys/user/UploadExcel",
				type: "POST",
		        data: formData,
		        async: false,
		        cache: false,
		        contentType: false,
		        processData: false,
                success : function(data) {
                	if (data != undefined && data.status != undefined
                			&& data.status.trim() == '0') {
                		result = true;
                		alert("保存成功！");
                		window.location.href = "${ctx}/sys/user/listUser";
                	} else {
                		result = false;
                		alert(data.error);
                	}
                },
    		},"json");
			return false;
		}
		</script>

	</body>


</html>